package cn.mldn.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * description:
 * Created by gy on 2017/8/21.
 */
@Configuration
public class ProducerConfig {

    public static final String EXCHANGE = "mldn.microboot.exchange";
    public static final String ROUTING_KEY = "mldn.microboot.routingkey";
    public static final String QUEUE_NAME = "mldn.microboot.queue";

    @Bean
    public Binding bindingExchangeQueue(DirectExchange exchange,Queue queue){
        return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY);
    }

    @Bean
    public DirectExchange getDirectExchange(){
        return new DirectExchange(EXCHANGE,true,true);
    }

    @Bean
    public Queue queue(){
        return new Queue(QUEUE_NAME);
    }
}
